package com.lianniu.mgr.teaInfo.controller;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.lianniu.mgr.base.BaseResult;
import com.lianniu.mgr.buyerManage.vo.BuyerConditionVo;
import com.lianniu.mgr.pagination.PaginationInfo;
import com.lianniu.mgr.teaInfo.model.TeaFrontusers;
import com.lianniu.mgr.teaInfo.service.ITeaInfoService;



@Controller
@RequestMapping("/rest/tea/info")
public class TeaRestInfoController {
	
	private final static Logger logger = Logger.getLogger(TeaRestInfoController.class);
	
	@Autowired
	private ITeaInfoService teaInfoService;
	/**
	 * 根据用户id查询用户信息
	 * @param req
	 * @return
	 */
	@RequestMapping(value="/getTeaInfo",method = {RequestMethod.POST,RequestMethod.GET} )
	public @ResponseBody BaseResult getTeaInfo(HttpServletRequest req){
		logger.info("TeaInfoController getTeaInfo begin.");
		try {
			logger.info("getTeaInfo begin.");
			String userId = req.getParameter("userId");
			BaseResult baseResult = teaInfoService.getTeaInfo(userId);
			logger.info("getTeaInfo end.");
			logger.info("TeaInfoController getTeaInfo end.");
			return baseResult;
		} catch (Exception e) {
			logger.error("TeaInfoController getTeaInfo error:" + e.getMessage());
			logger.error("TeaInfoController getTeaInfo end.");
			return BaseResult.exception(e.getMessage());
		}
	}
	
	
	@RequestMapping(value="/teaInfoList",method = {RequestMethod.POST,RequestMethod.GET} )
	public @ResponseBody BaseResult teaInfoList(TeaFrontusers teaFrontusers, HttpServletRequest req, PaginationInfo paginationInfo){
		logger.info("TeaInfoController teaInfoList begin.");
		try {
			logger.info("teaInfoList begin.");
			String userId = req.getParameter("userId");
			BaseResult baseResult = teaInfoService.selectAllUser(teaFrontusers, paginationInfo);
			logger.info("teaInfoList end.");
			logger.info("TeaInfoController teaInfoList end.");
			return baseResult;
		} catch (Exception e) {
			logger.error("TeaInfoController teaInfoList error:" + e.getMessage());
			logger.error("TeaInfoController teaInfoList end.");
			return BaseResult.exception(e.getMessage());
		}
	}
}
